﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Dimebrain.TweetSharp.Fluent;
using Dimebrain.TweetSharp.Model.Twitter;
using Dimebrain.TweetSharp.Extensions;
using Dimebrain.TweetSharp.Model;

namespace TwKarma.Web.Service.Process
{
	public class SearchTwitter
	{
		private string _hashtag;
		private DateTime _since;

		public SearchTwitter(string hashtag, DateTime since)
		{
			_hashtag = hashtag;
			_since = since;
		}

		public List<TwitterSearchStatus> GetResults()
		{
			TwitterResult result = FluentTwitter.CreateRequest().Search().Query().ContainingHashTag(_hashtag).Since(_since).Take(100).AsJson().Request();
			if (result.IsTwitterError)
				return null;

			return result.AsSearchResult().Statuses;

		}
	}
}